package cn.bandeqing.index.controller;

import cn.bandeqing.base.resp.Resp;
import cn.bandeqing.index.req.ProductRecommendListReq;
import cn.bandeqing.index.resp.BannerResp;
import cn.bandeqing.index.resp.ProductTypeResp;
import cn.bandeqing.index.rpc.IIndexRpc;
import cn.bandeqing.product.resp.ProductListResp;
import cn.bandeqing.sys.resp.DictResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.hutool.core.collection.ListUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RequestMapping("/index")
@RestController
@Tag(name = "首页资源")
public class IndexController {

    @DubboReference
    private IIndexRpc indexRpc;

    @Operation(summary = "首页推荐产品")
    @PostMapping("/productRecommendList")
    public Resp<List<ProductListResp>> productRecommendList(@RequestBody @Valid ProductRecommendListReq req) {
        return indexRpc.productRecommendList(req);
    }

    @Operation(summary = "首页产品类型")
    @PostMapping("/productTypeList")
    public Resp<List<ProductTypeResp>> productTypeList() {
        return indexRpc.productTypeList();
    }

    @Operation(summary = "首页热销套餐")
    @PostMapping("/productHotList")
    public Resp<List<ProductListResp>> productHotList() {
        return indexRpc.productHotList();
    }

    @Operation(summary = "首页banner")
    @PostMapping("/banners")
    public Resp<List<BannerResp>> banners() {

        ArrayList<BannerResp> banners = ListUtil.of(
                BannerResp.builder().imageUrl("https://bdqfile.bmbanjia.cn/index/banner/banner_0.png").build(),
                BannerResp.builder().imageUrl("https://bdqfile.bmbanjia.cn/index/banner/banner_1.png").build(),
                BannerResp.builder().imageUrl("https://bdqfile.bmbanjia.cn/index/banner/banner_2.png").build()
        );

        return Resp.success(banners);
    }

}
